package part1.api.file.filetest;

import java.io.File;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException {
        File file = new File("text1.txt");
        System.out.println(file.getName());
        System.out.println(file.length());
        System.out.println(file.isHidden());
        System.out.println(file.canRead());
        System.out.println(file.canWrite());
        System.out.println(file.exists());

        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        if (!file.isFile()){
            file.createNewFile();
        }
        if (!file.isDirectory()){
            file.mkdirs();
        }
        if (file.exists()){
            file.delete();
        }

        File dir = new File(".");
        File[] files = dir.listFiles(file1 -> file1.getName().contains("s"));
        for (File f : files){
            System.out.println(f.getName());
        }

    }
}
